package com.passion.mq.util;

import com.passion.mq.config.RabbitMqConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeansException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 类描述：消息队列工具类
 *
 * @author ZhuYin
 * @since 2024年12月03日
 */
@Slf4j
@Component
@ConditionalOnBean(RabbitMqConfig.class)
@SuppressWarnings("unused")
public class RabbitMqUtil implements ApplicationContextAware {

    private static RabbitTemplate rabbitTemplate;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        RabbitMqUtil.rabbitTemplate = applicationContext.getBean(RabbitTemplate.class);
    }


}
